package com.example.huashangapp;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.ref.SoftReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONException;
import org.json.JSONObject;

import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.app.Application;
import android.app.NotificationManager;
import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Environment;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.widget.ImageView;
import android.widget.Toast;

import com.baidu.location.BDLocation;
import com.baidu.mapapi.BMapManager;
import com.baidu.mapapi.MKGeneralListener;
import com.baidu.mapapi.map.MKEvent;
import com.example.DBHelper.Dao;
import com.example.entity.ShareEntity;
import com.example.net.NetRequest;
import com.example.service.MainService;
import com.example.service.Mp3Service;
import com.example.service.Mp3Service.MyBinder;
import com.example.ui.IndexActivity;
import com.example.ui.MainActivity;
import com.example.ui.contact.bean.User;
import com.example.ui.contact.chat.SharePreferenceUtil;
import com.example.ui.contact.db.ChatMsgDB;
import com.example.ui.contact.db.CommentMsgDB;
import com.example.ui.contact.db.MeMsgDB;
import com.example.ui.contact.db.MessageDB;
import com.example.ui.contact.db.MessageHelper;
import com.example.ui.contact.db.NoticeMsgDB;
import com.example.ui.contact.db.PraiseMsgDB;
import com.example.ui.contact.db.RecentMsgDB;
import com.example.ui.contact.db.RequestMsgDB;
import com.example.ui.contact.db.UserDB;
import com.example.ui.contact.face.FaceUtil;
import com.example.ui.learn.ListeningActivity;
import com.example.ui.learn.ListeningInfo;
import com.example.ui.learn.util.CurriculumCenter;
import com.example.ui.learn.util.CurriculumCenter2;
import com.example.ui.learn.util.MyClassroom;
import com.example.ui.learn.util.Recommend;
import com.example.util.AsyncLoadImage;
import com.example.util.PhotoUtil;
import com.example.util.Tools;
import com.example.util.Util;
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;

@SuppressLint("WorldReadableFiles")
public class HSApplication extends Application {
	
	public static HSApplication mInstance=null;
	public static final String SPNAME = "listening";
	public static final ListeningInfo HSlistInfo=new ListeningInfo(); //试听的一级目录
	 public static String url;//背景图片
	public static ArrayList<CurriculumCenter> item1_cc=new ArrayList<CurriculumCenter>();//选课中心一级目录
	public static  Map<String,ArrayList<CurriculumCenter2>> item1_cca_cc = new HashMap<String,ArrayList<CurriculumCenter2>>();//选课中心二及目录
	public static ArrayList<MyClassroom> i2_mc=new ArrayList<MyClassroom>();//我的收藏一级目录
	public static Map<String, ArrayList<Recommend>>  ra_list= new HashMap<String,ArrayList<Recommend>>();//线下课程活动一级目录
	public static ArrayList<CurriculumCenter> item4_cc=new ArrayList<CurriculumCenter>();//华商访谈一级目录
	public static Map<String,ArrayList<CurriculumCenter2>>  item4_cca_cc=new HashMap<String,ArrayList<CurriculumCenter2>>();//华商访谈二级目录
	public static Dao dao=null;
	public static Dao getDao() {
		if(dao==null){
			dao=new Dao(getInstance());
		}
		return dao;
	}
	//	public static String myID ;
//	public static String myName ;
	/**
	 * 地图
	 */
	public BDLocation currlocation = null;// 定位结果
	public BMapManager mBMapManager = null;
	public static final String mapKey = "95B6A0BC214EEBC3AED70BF8E0DCF2EDED5D4208";
	public boolean m_bKeyRight = true;
	public static SharedPreferences sp;
	public static Editor spEditor;
	public static  HSApplication getInstance(){
		return mInstance;
	}
	public static String netWorkType;
	//发表分享时  上传图片的路径
	//public static StringBuffer sb = new StringBuffer();
	public static Map<String,Object> uploadTempImgMap =new HashMap<String,Object>();
	public static List<String> uploadTempImgList =new ArrayList<String>();
	/**
	 * 手机SD卡图片的路径
	 */
	public static Map<String, List<Map<String, String>>> albumMap = new HashMap<String, List<Map<String, String>>>();
	/**
	 * 存放本地选取的照片集合
	 */
	public static List<Map<String, String>> mAlbumList = new ArrayList<Map<String, String>>();
	/**
	 * 手机SD卡图片缓存
	 */
	public static HashMap<String, SoftReference<Bitmap>> mPhoneAlbumCache = new HashMap<String, SoftReference<Bitmap>>();
	
	/**
	 * 当期  最新分享  数据
	 */
	public List<ShareEntity> shareEntity = new ArrayList<ShareEntity>();
	/**
	 * 分享 页面 图片缓存
	 */
	public HashMap<String, SoftReference<Bitmap>> mHomeCache = new HashMap<String, SoftReference<Bitmap>>();
	/**
	 * 默认头像
	 */
	public Bitmap mDefault_Avatar;
	/**
	 * 头像名称
	 */
	public String[] mAvatars;
	/**
	 * 圆形头像缓存
	 */
	public HashMap<String, SoftReference<Bitmap>> mAvatarCache = new HashMap<String, SoftReference<Bitmap>>();
	/**
	 * 表情名称
	 */
	public List<String> mFacesText = new ArrayList<String>();
	/**
	 * 表情缓存
	 */
	public HashMap<String, SoftReference<Bitmap>> mFaceCache = new HashMap<String, SoftReference<Bitmap>>();
	/**
	 * 表情
	 */
	public int[] mFaces = { R.drawable.angry, R.drawable.bigsurprise,
			R.drawable.blank, R.drawable.cheese, R.drawable.confused,
			R.drawable.downer, R.drawable.embarrassed, R.drawable.exclaim,
			R.drawable.grin, R.drawable.grrr, R.drawable.gulp,
			R.drawable.hmm, R.drawable.kiss, R.drawable.lol,
			R.drawable.longface, R.drawable.mad, R.drawable.ohh,
			R.drawable.ohoh, R.drawable.question, R.drawable.raspberry,
			R.drawable.rolleyes, R.drawable.shade_cheese, R.drawable.shade_grin,
			R.drawable.shade_hmm, R.drawable.shade_mad, R.drawable.shade_smile,
			R.drawable.shade_smirk, R.drawable.shock, R.drawable.shuteye,
			R.drawable.sick, R.drawable.smile, R.drawable.smirk,
			R.drawable.snake, R.drawable.surprise, R.drawable.tongue_laugh,
			R.drawable.tongue_rolleye, R.drawable.tongue_wink, R.drawable.vampire,
			R.drawable.wink, R.drawable.zip};
	/*
	 *  Leone begin
	 */
	public static MessageHelper msgHelper;
	
	
	public final static String API_KEY = "cryBTjWNGUM0ctYwCCV9h8WU";  
	public final static String SECRIT_KEY = "GsxZ8ZR6fBrxDWkO90VW2LixQfzweWsd";
	public static final String SP_FILE_NAME = "huashuang_msg_sp";
	private List<User> mUserList;
	private NotificationManager mNotificationManager;
	private SharePreferenceUtil mSpUtil;
	private UserDB mUserDB;
	private MessageDB mMsgDB;
	private MeMsgDB meMsgDB;
	private CommentMsgDB commentMsgDB;
	private PraiseMsgDB praiseMsgDB;
	private NoticeMsgDB noticeMsgDB;
	private RequestMsgDB requestMsgDB;
	private ChatMsgDB chatMsgDB;
	private RecentMsgDB recentMsgDB;
	private FaceUtil faceUtil;
	private Map<String, Integer> mFaceMap = new LinkedHashMap<String, Integer>();
	private Intent intentMP3;
	public static final int NUM_PAGE = 3;// 总共有多少页
	public static int NUM = 20;      // 每曰20个表情
	public static String mSdcardDataDir;
	public NotificationManager getNotificationManager() {
		if (mNotificationManager == null)
			mNotificationManager = (NotificationManager) getSystemService(android.content.Context.NOTIFICATION_SERVICE);
		return mNotificationManager;
	}
	
	public synchronized SharePreferenceUtil getSpUtil() {
		if (mSpUtil == null)
			mSpUtil = new SharePreferenceUtil(this, SP_FILE_NAME);
		return mSpUtil;
	}
	public synchronized MessageDB getMessageDB() {
		if (mMsgDB == null)
			mMsgDB = new MessageDB(this);
		return mMsgDB;
	}
	public synchronized MeMsgDB getMeMsgDB() {
		if (meMsgDB == null)
			meMsgDB = new MeMsgDB(this);
		return meMsgDB;
	}	
	
	public synchronized CommentMsgDB getCommentMsgDB() {
		if (commentMsgDB == null)
			commentMsgDB = new CommentMsgDB(this);
		return commentMsgDB;
	}
	public synchronized PraiseMsgDB getPraiseMsgDB() {
		if (praiseMsgDB == null)
			praiseMsgDB = new PraiseMsgDB(this);
		return praiseMsgDB;
	}	
	public synchronized NoticeMsgDB getNoticeMsgDB() {
		if (noticeMsgDB == null)
			noticeMsgDB = new NoticeMsgDB(this);
		return noticeMsgDB;
	}
	
	public synchronized RequestMsgDB getRequestMsgDB() {
		if (requestMsgDB == null)
			requestMsgDB = new RequestMsgDB(this);
		return requestMsgDB;
	}

	public synchronized ChatMsgDB getChatMsgDB() {
		if (chatMsgDB == null)
			chatMsgDB = new ChatMsgDB(this);
		return chatMsgDB;
	}
	public synchronized RecentMsgDB getRecentMsgDB() {
		if (recentMsgDB == null)
			recentMsgDB = new RecentMsgDB(this);
		return recentMsgDB;
	}
	
	public synchronized UserDB getUserDB() {
		if (mUserDB == null)
			mUserDB = new UserDB(this);
		return mUserDB;
	}
	public synchronized List<User> getUserList() {
		if (mUserList == null)
			mUserList = getUserDB().getUser();
		return mUserList;
	}
	public synchronized FaceUtil getFaceUtil() {
		if (faceUtil == null)
			faceUtil = new FaceUtil(this);
		return faceUtil;
	}
	private void initFaceMap() {
		mFaceMap.put("':-)'", R.drawable.grin);
		mFaceMap.put("':lol:'", R.drawable.lol);
		mFaceMap.put("':cheese:'", R.drawable.cheese);
		mFaceMap.put("':)'", R.drawable.smile);
		mFaceMap.put("':;-)'", R.drawable.wink);
		mFaceMap.put("':;)'", R.drawable.wink);
		mFaceMap.put("':smirk:'", R.drawable.smirk);
		mFaceMap.put("':roll:'", R.drawable.rolleyes);
		mFaceMap.put("':-S'", R.drawable.confused);
		mFaceMap.put("':wow:'", R.drawable.surprise);
		mFaceMap.put("':bug:'", R.drawable.bigsurprise);
		mFaceMap.put("':-P'", R.drawable.tongue_laugh);
		mFaceMap.put("':%-P'", R.drawable.tongue_rolleye);
		mFaceMap.put("':;-P'", R.drawable.tongue_wink);
		mFaceMap.put("'::P'", R.drawable.raspberry);
		mFaceMap.put("':blank:'", R.drawable.blank);
		mFaceMap.put("':long:'", R.drawable.longface);
		mFaceMap.put("':ohh:'", R.drawable.ohh);
		mFaceMap.put("':grrr:'", R.drawable.grrr);
		mFaceMap.put("':gulp:'", R.drawable.gulp);
		mFaceMap.put("':8-/'", R.drawable.ohoh);
		mFaceMap.put("':down:'", R.drawable.downer);
		mFaceMap.put("':red:'", R.drawable.embarrassed);
		mFaceMap.put("':sick:'", R.drawable.sick);
		mFaceMap.put("':shut:'", R.drawable.shuteye);
		mFaceMap.put("':-/'", R.drawable.hmm);
		mFaceMap.put("':):('", R.drawable.mad);
		mFaceMap.put("':mad:'", R.drawable.mad);
		mFaceMap.put("':):-('", R.drawable.angry);
		mFaceMap.put("':angry:'", R.drawable.angry);
		mFaceMap.put("':zip:'", R.drawable.zip);
		mFaceMap.put("':kiss:'", R.drawable.kiss);
		mFaceMap.put("':ahhh:'", R.drawable.shock);
		mFaceMap.put("':coolsmile:'", R.drawable.shade_smile);
		mFaceMap.put("':coolsmirk:'", R.drawable.shade_smirk);
		mFaceMap.put("':coolgrin:'", R.drawable.shade_grin);
		mFaceMap.put("':coolhmm:'", R.drawable.shade_hmm);
		mFaceMap.put("':coolmad:'", R.drawable.shade_mad);
		mFaceMap.put("':coolcheese:'", R.drawable.shade_cheese);
		mFaceMap.put("':vampire:'", R.drawable.vampire);
		mFaceMap.put("':snake:'", R.drawable.snake);
		mFaceMap.put("':exclaim:'", R.drawable.exclaim);
		mFaceMap.put("':question:'", R.drawable.question);
		
		
	}

	public Map<String, Integer> getFaceMap() {
		if (!mFaceMap.isEmpty())
			return mFaceMap;
		return null;
	}	
	
	/*
	 * Leone end 
	 */
	
	@SuppressLint("WorldWriteableFiles")
	@SuppressWarnings("deprecation")
	@Override
	public void onCreate() {
		super.onCreate();
		mInstance=this;
		msgHelper = new MessageHelper(this);
		//开启MP3播放服务
		
		sp= mInstance.getSharedPreferences(SPNAME,MODE_PRIVATE);
		spEditor = sp.edit();
		netWorkType=setNetworkType();
		MainService.OpenPhoneListen(this);
		mSdcardDataDir=Environment.getExternalStorageState();
		initEngineManager(this);// 启动定位
		LBSLocation.getInstance(this).startLocation();
		mDefault_Avatar = PhotoUtil.toRoundCorner(
				BitmapFactory.decodeResource(getResources(), R.drawable.nan2),
				15);
		try {
			mAvatars = getAssets().list("avatar");
		} catch (IOException e) {
			e.printStackTrace();
		}
		/**
		 * 初始化表情名称
		 */
		for (int i = 0; i < mFaces.length; i++) {
			mFacesText.add("[face_" + i + "]");
		}
		ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())  

        .threadPriority(Thread.NORM_PRIORITY - 2)  

        .denyCacheImageMultipleSizesInMemory()  

        .discCacheFileNameGenerator(new Md5FileNameGenerator())  

        .tasksProcessingOrder(QueueProcessingType.LIFO)

        .enableLogging() // Not necessary in common  

        .build();  
		ImageLoader.getInstance().init(config);  
		initFaceMap();
		asyncLoadImage=new AsyncLoadImage();
		mSpUtil = new SharePreferenceUtil(this, SP_FILE_NAME);
	}
	
	/**
	 * 根据图片名称获取主页图片
	 */
	public Bitmap getHome(String photo) {
		try {
			String homeName = photo + ".jpg";
			Bitmap bitmap = null;
			if (mHomeCache.containsKey(homeName)) {
				SoftReference<Bitmap> reference = mHomeCache.get(homeName);
				bitmap = reference.get();
				if (bitmap != null) {
					return bitmap;
				}
			}
			bitmap = BitmapFactory.decodeStream(getAssets().open(
					"home/" + homeName));
			mHomeCache.put(homeName, new SoftReference<Bitmap>(bitmap));
			return bitmap;
		} catch (Exception e) {
			return BitmapFactory.decodeResource(getResources(),
					R.drawable.picture_default_fg);
		}
	}
	
	/**
	 * 根据编号获取表情图片
	 */
	public Bitmap getFaceBitmap(int position) {
		try {
			String faceName = mFacesText.get(position);
			Bitmap bitmap = null;
			if (mFaceCache.containsKey(faceName)) {
				SoftReference<Bitmap> reference = mFaceCache.get(faceName);
				bitmap = reference.get();
				if (bitmap != null) {
					return bitmap;
				}
			}
			bitmap = BitmapFactory.decodeResource(getResources(),
					mFaces[position]);
			mFaceCache.put(faceName, new SoftReference<Bitmap>(bitmap));
			return bitmap;
		} catch (Exception e) {
			return null;
		}
	}
	/**
	 * 根据编号获取用户圆形头像
	 */
	public Bitmap getAvatar(int position) {
		try {
			String avatarName = mAvatars[position];
			Bitmap bitmap = null;
			if (mAvatarCache.containsKey(avatarName)) {
				SoftReference<Bitmap> reference = mAvatarCache.get(avatarName);
				bitmap = reference.get();
				if (bitmap != null) {
					return bitmap;
				}
			}
			bitmap = PhotoUtil.toRoundCorner(
					BitmapFactory.decodeStream(getAssets().open(
							"avatar/" + avatarName)), 15);
			mAvatarCache.put(avatarName, new SoftReference<Bitmap>(bitmap));
			return bitmap;
		} catch (Exception e) {
			return mDefault_Avatar;
		}
	}
	
	
	
	
	
	
	/**
	 *地图
	 */

	public void initEngineManager(Context context) {
       /* if (mBMapManager == null) {
            mBMapManager = new BMapManager(context);
        }*/
       /* if (!mBMapManager.init(mapKey,new MyGeneralListener())) {
           // Util.toast(HSApplication.getInstance().getApplicationContext(), "BMapManager  初始化错误!");
        }*/
	}
	// 常用事件监听，用来处理通常的网络错误，授权验证错误等
    public static class MyGeneralListener implements MKGeneralListener {
        @Override
        public void onGetNetworkState(int iError) {
            if (iError == MKEvent.ERROR_NETWORK_CONNECT) {
            	Util.toast(HSApplication.getInstance().getApplicationContext(), "您的网络出错啦！");
            }
            else if (iError == MKEvent.ERROR_NETWORK_DATA) {
            	Util.toast(HSApplication.getInstance().getApplicationContext(), "输入正确的检索条件！");
            }
            // ...
        }
        @Override
        public void onGetPermissionState(int iError) {
            if (iError ==  MKEvent.ERROR_PERMISSION_DENIED) {
                //授权Key错误：请在 DemoApplication.java文件输入正确的授权Key！
            	Util.toast(HSApplication.getInstance().getApplicationContext(), "授权Key错误");
                HSApplication.getInstance().m_bKeyRight = false;
            }
        }
    }

	@Override
	//建议在您app的退出之前调用mapadpi的destroy()函数，避免重复初始化带来的时间消耗
	public void onTerminate() {
	    if (mBMapManager != null) {
            mBMapManager.destroy();
            mBMapManager = null;
        }
		super.onTerminate();
	}
    
	/**
	 * 根据地址获取手机SD卡图片
	 */
	public static Bitmap getPhoneAlbum(String path) throws Exception{
		Bitmap bitmap = null;
		if (mPhoneAlbumCache.containsKey(path)) {
			SoftReference<Bitmap> reference = mPhoneAlbumCache.get(path);
			bitmap = reference.get();
			if (bitmap != null) {
				return bitmap;
			}
		}
		bitmap = BitmapFactory.decodeFile(path);
		mPhoneAlbumCache.put(path, new SoftReference<Bitmap>(bitmap));
		return bitmap;
		
	}
	
	/**
	 * 设置手机网络类型，wifi，cmwap，ctwap，用于联网参数选择
	 * @return
	 */
	public static String setNetworkType() {
		String networkType = "wifi";
		ConnectivityManager manager = (ConnectivityManager) mInstance
				.getSystemService(Context.CONNECTIVITY_SERVICE);

		NetworkInfo netWrokInfo = manager.getActiveNetworkInfo();
		if (netWrokInfo == null || !netWrokInfo.isAvailable()) {
			// 当前网络不可用
			return "";
		}

		String info = netWrokInfo.getExtraInfo();
		if ((info != null)
				&& ((info.trim().toLowerCase().equals("cmwap"))
						|| (info.trim().toLowerCase().equals("uniwap"))
						|| (info.trim().toLowerCase().equals("3gwap")) || (info
						.trim().toLowerCase().equals("ctwap")))) {
			// 上网方式为wap
			if (info.trim().toLowerCase().equals("ctwap")) {
				// 电信
				networkType = "ctwap";
			} else {
				networkType = "cmwap";
			}

		}
		
//		spEditor.putString("netType", networkType);
		return "mobile";
	}
	/**
     * 获取外置SD卡路径
     * 
     * @return
     */
    public static String getSDCardPath() {
        String cmd = "cat /proc/mounts";
        Runtime run = Runtime.getRuntime();// 返回与当前 Java 应用程序相关的运行时对象
        try {
            Process p = run.exec(cmd);// 启动另一个进程来执行命令
            BufferedInputStream in = new BufferedInputStream(p.getInputStream());
            BufferedReader inBr = new BufferedReader(new InputStreamReader(in));
            String lineStr;
            while ((lineStr = inBr.readLine()) != null) {
                // 获得命令执行后在控制台的输出信息
            	Log.i("CommonUtil:getSDCardPath", lineStr);
                if (lineStr.contains("sdcard")
                        && lineStr.contains(".android_secure")) {
                    String[] strArray = lineStr.split(" ");
                    if (strArray != null && strArray.length >= 5) {
                        String result = strArray[1].replace("/.android_secure",
                                "");
                        return result;
                    }
                }
                // 检查命令是否执行失败。
                if (p.waitFor() != 0 && p.exitValue() == 1) {
                    // p.exitValue()==0表示正常结束，1：非正常结束
                	Log.e("CommonUtil:getSDCardPath", "命令执行失败!");
                }
            }
            inBr.close();
            in.close();
        } catch (Exception e) {
            Log.e("CommonUtil:getSDCardPath", e.toString());

            return Environment.getExternalStorageDirectory().getPath();
        }

        return Environment.getExternalStorageDirectory().getPath();
    }

   public static String getExternalStorageDirectory() {  
    	    Map<String, String> map = System.getenv();  
    	    String[] values = new String[map.values().size()];  
    	    map.values().toArray(values);  
    	    String path = values[values.length - 1];    //外置SD卡的路径  
    	    if (path.startsWith("/mnt/") && !Environment.getExternalStorageDirectory().getAbsolutePath().equals(path)){  
    	        return path;  
    	    }else{  
    	        return null;  
    	    }  
    	}  
   /**
    * 用来判断服务是否运行.
    * @param context
    * @param className 判断的服务名字
    * @return true 在运行 false 不在运行
    */
	public static boolean isServiceRunning(Context mContext,String className) {
       boolean isRunning = false;
       ActivityManager activityManager = (ActivityManager)
       mContext.getSystemService(Context.ACTIVITY_SERVICE); 
       List<ActivityManager.RunningServiceInfo> serviceList 
                  = activityManager.getRunningServices(30);
       if (!(serviceList.size()>0)) {
           return false;
       }
       for (int i=0; i<serviceList.size(); i++) {
           if (serviceList.get(i).service.getClassName().equals(className) == true) {
               isRunning = true;
               break;
           }
       }
       return isRunning;
   }
public	static Handler handler = new Handler() {
		private Intent intent;
		@Override
		public void handleMessage(Message msg) {
			switch (msg.what) {
			case 1:
				if(Mp3Service.mp!=null){
					intent = new Intent(Tools.ACTION_CTIME);
					intent.putExtra("currentTime", Mp3Service.mp.getCurrentPosition());
					mInstance.sendBroadcast(intent);
				
					handler.sendEmptyMessageDelayed(1, 500);
					intent = new Intent(Tools.ACTION_TTIME);
					intent.putExtra("totaltime", Mp3Service.mp.getDuration());
					mInstance.sendBroadcast(intent);
				}
				break;
			case 2:
				intent = new Intent(Tools.ACTION_COMPLETION);
				intent.putExtra("loop",Tools.LOOP_ORDER);
				mInstance.sendBroadcast(intent);
				break;
			default:
				break;
			}
			super.handleMessage(msg);
		}
	};
public  static AsyncLoadImage asyncLoadImage;
}
